package com.chukun.flink.dataset.operator;

import org.apache.flink.api.java.DataSet;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.operators.DataSource;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.tuple.Tuple3;

import java.util.ArrayList;
import java.util.List;

/**
 * @author chukun
 * @version 1.0.0
 * @description project 操作符的基本操作
 * @createTime 2022年05月28日 20:35:00
 */
public class ProjectOperator {

    public static void main(String[] args) throws Exception {

        ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

        List<Tuple3<String, Integer, String>> list = new ArrayList<>();
        list.add(new Tuple3<>("185XXX", 899, "周一"));
        list.add(new Tuple3<>("155XXX", 1199, "周二"));
        list.add(new Tuple3<>("138XXX", 19, "周三"));

        DataSource<Tuple3<String,Integer,String>> dataSource = env.fromCollection(list);

        DataSet<Tuple2<Long, Integer>> projectData = dataSource.project(0,2);

        projectData.print("project");

        env.execute("ProjectOperator");
    }
}
